<template>
  <div class="no-permission">
    <a-result
      status="403"
      title="无访问权限"
      sub-title="当前账号没有访问该页面的权限，请联系管理员分配权限。"
    >
      <template #extra>
        <a-button type="primary" @click="goHome">返回首页</a-button>
      </template>
    </a-result>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from "vue-router";

const router = useRouter();

const goHome = () => {
  // 简单判断：平台管理员回平台首页，其他用户回租户首页
  const isPlatform = location.pathname.startsWith("/platform");
  router.push(isPlatform ? "/platform/dashboard" : "/tenant/dashboard");
};
</script>

<style scoped>
.no-permission {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
